package org.atguigu.beanlife.bean;

import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * @Author:lyd
 **/
@Data
public class User implements InitializingBean, DisposableBean {
    private String name;
    private String password;
    private Address address;

    @Autowired
    public void setAddress(Address address) {
        System.out.println("setName--->>set属性注入");
    }

    public User(String name, String password) {
        this.name = name;
        this.password = password;
    }
    public User() {
        System.out.println("无参构造执行");
    }
    public void initUser() {
        System.out.println("init--->>执行");
    }
    public void destroyUser() {
        System.out.println("destroy--->>执行");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("afterPropertiesSet--->>执行");
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("afterPropertiesSet--->>执行");
    }
    @PostConstruct
    public void initByPostConstruct() {
        System.out.println("@PostConstruct--->>执行");
    }
    @PreDestroy
    public void destroyByPreDestroy() {
        System.out.println("@PreDestroy--->>执行");
    }


}
